import Vue from "vue"
import vuex from 'vuex'
// import tabBar from '../untlis/tabbar.js' // 引入untlis中自定义的tabber属性文件

Vue.use(vuex)

export default new vuex.Store({
    state: {
       baseUrl: 'https://recovery.gxqichang.cn', //服务器//https://re.gxqichang.cn  //本地//http://www.zrx.com  //20221108a 新wx9cf5fb3e25bbb27e
        // baseUrl: 'http://oldrecovery.com',  //服务器//https://re.gxqichang.cn  //本地//http://www.zrx.com  //20221108a //旧wx08c3a6c6ddcd7e4f
//        baseUrl: 'https://re.gxqichang.cn',  //服务器//https://re.gxqichang.cn  //本地//http://www.zrx.com  //20221108a //旧wx08c3a6c6ddcd7e4f
		
        total: 0,
        // 自定义tabbats当前激活的index
        active: 0,
        shopActive: 0,
        // tabBarList: tabBar,
        userInfo: {},
        session_key: '',
        wptypelist: [],
        isUserEdit: 0,
        invitecode: null,
        isEditOrder: 0,
        isOrder: 0,
        //20221105
        MQTT_NUMBER: 1, //默认1号地磅
        MQTT_IP: "hsdzmqtt.hsdzyun.com",
        MQTT_PORT: 7109,
        MQTT_USERNAME: "admin",
        MQTT_PASSWORD: "hsdz",
        MQTT_OPTIONS: {
            connectTimeout: 5000,
            clientId: "",
            username: "",
            password: "",
            clean: false
        },
        wpps: [],
    },
    mutations: {
        countadd(state) {
            state.total++
        },
        // 改变当前tabbar的激活状态
        changeactive(state, options) {
            state.active = options
        },
        // 改变当前商城tabbar的激活状态
        changeShopActive(state, options) {
            state.shopActive = options
        },
        // 设置用户信息
        setUserInfo(state, userInfo) {
            state.userInfo = userInfo
        },
        // 设置key
        setSessionKey(state, key) {
            state.session_key = key
        },
        // 物品类型
        setWptypeList(state, list) {
            state.wptypelist = list
            uni.setStorageSync('setWptypeList',list)
        },
        // 设置用户修改状态
        setIsUserEdit(state, isUserEdit) {
            state.isUserEdit = isUserEdit
        },
        // 设置用户修改状态
        setInvitecode(state, invitecode) {
            state.invitecode = invitecode
        },
        // 设置回收员编辑
        setEditOrder(state, isEditOrder) {
            state.isEditOrder = isEditOrder
        },
        // 设置回收员编辑
        setOrder(state, isOrder) {
            state.isOrder = isOrder
        },

        getWp(state, dataWp) {
            state.wpps.push(dataWp)
        },
        deleteWp(state, index) {
            state.wpps.splice(index, 1)
        },
        updateWp(state, {
            index,
            value
        }) {
            state.wpps[index] = value
        }
    }
})